<template>
  <div class="epMain">
    <div class="epList">
      <div class="head_crumbs clearfix">
        <img src="~@img/public/icon-gdyx&gzzk.png" alt="" />
        <span>{{ tips }}：{{ size }}所</span>
        <span class="go_back" @click="$router.go(-1)">返回</span>
      </div>
      <div class="list" v-if="size != 0">
        <div
          class="list_item"
          v-for="item of List"
          :key="item.id"
          @click="goDetails(item.id)"
        >
          <p class="item_title">{{ item.name }}</p>
          <p class="division"></p>
          <p class="flex_p">
            <span
              >高校类型：<span>{{ item.category }}</span>
            </span>
            <span
              >办学性质：<span>{{ item.nature }}</span>
            </span>
            <span
              >创办时间：<span>{{ item.buildate }} </span></span
            >
          </p>
          <strong>
            查看详情
          </strong>
        </div>
      </div>
      <el-pagination
        v-if="size != 0"
        @current-change="handleCurrentChange"
        :current-page.sync="currentPage"
        :page-size="10"
        layout=" prev, pager, next,jumper"
        :total="size"
      >
      </el-pagination>
      <div class="none" v-if="List.length == 0">
        <img src="~@img/public/img-result-none.png" alt="" />
        <div>很抱歉，没有找到相关信息~</div>
      </div>
    </div>
  </div>
</template>

<script>
import { compList } from "@api/list";
export default {
  data() {
    return {
      currentPage: 1,
      per_page: 10,
      classify: 2,
      activeMenu: "",
      size: 0,
      List: [],
      tips: "",
      old_url: "",
    };
  },
  watch: {
    "$route.path": function(nv, ov) {
      if (this.$route.name == "schoolList" && nv != this.old_url) {
        this.old_url = this.$route.path;
        this.activeMenu = this.$route.params.activeMenu;
        this.type = parseInt(this.$route.params.type);
        switch (this.type) {
          case 1:
            this.tips = "高等院校";
            break;
          case 2:
            this.tips = "高职高专";
            break;
        }
        this.district = this.$route.params.district;
        this.$bus.$emit("setActive", this.activeMenu);
        this.old_url = nv;
        this.currentPage = 1;
        this.getList();
      }
    },
  },
  mounted() {
    this.old_url = this.$route.path;
    this.activeMenu = this.$route.params.activeMenu;
    this.type = parseInt(this.$route.params.type);
    switch (this.type) {
      case 1:
        this.tips = "高等院校";
        break;
      case 2:
        this.tips = "高职高专";
        break;
    }
    this.district = this.$route.params.district;
    this.$bus.$emit("setActive", this.activeMenu);
    this.getList();
  },
  methods: {
    async getList() {
      let res = await compList({
        classify: this.classify,
        type: this.type,
        district: this.district,
        page: this.currentPage,
        perpage: this.per_page,
      });
      if (res.code && res.code != 0) {
        this.List = [];
        this.size = 0;
      } else {
        this.List = res.data_list;
        this.size = res.size;
      }
    },
    goDetails(id) {
      this.$router.push({
        name: "school",
        params: { id, activeMenu: this.activeMenu, type: 1 },
      });
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getList(val);
    },
  },
};
</script>

<style lang="less" scoped>
.epMain {
  width: 100%;
  height: 100%;
  background: #fafafa;
  overflow: hidden;
  .epList {
    box-sizing: border-box;
    margin: 0 auto;
    width: 1500px;
    height: 100%;
    .list {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
    }
  }
}
.none {
  text-align: center;
  font-size: 18px;
  color: #666;
  margin: 180px;
  img {
    width: 234px;
  }
  div {
    margin: 20px;
  }
}

.list_item {
  position: relative;
  box-sizing: border-box;
  margin-bottom: 20px;
  padding: 0 14px 0 46px;
  width: 740px;
  height: 116px;
  background: #ffffff;
  box-shadow: 0px 0px 6px 0px rgba(86, 86, 86, 0.2);
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  .item_title {
    height: 72px;
    line-height: 72px;
    font-size: 22px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #333333;
    text-align: left;
  }

  .division {
    width: 98%;
    height: 2px;
    border-radius: 2px;
    background: #eeeeee;
  }
  .flex_p {
    height: 42px;
    line-height: 42px;
    width: 98%;
    display: flex;
    justify-content: space-between;
    span {
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #999999;
      span {
        color: #333;
      }
    }
  }
  strong {
    position: absolute;
    right: 30px;
    top: 40px;
    margin-top: -14px;
    font-size: 18px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #aaaaaa;
    padding-right: 20px;

    &::after {
      position: absolute;
      right: 0;
      top: 0;
      display: block;
      width: 18px;
      height: 28px;
      content: "";
      background: url("~@img/public/icon-information-normal.png") no-repeat
        center;
    }
  }
  &:hover {
    .item_title {
      font-size: 22px;
      font-weight: bold;
      color: #446db3;
    }

    &::after {
      position: absolute;
      top: 0;
      left: -1px;
      display: inline-block;
      content: "";
      width: 7px;
      height: 100%;
      background: #446db3;
      border-radius: 6px 0px 0px 6px;
    }
    strong {
      color: #446db3;
      &::after {
        background: url("~@img/public/icon-information-hover.png") no-repeat
          center;
      }
    }
  }
}
.head_crumbs {
  height: 70px;
  line-height: 70px;
  font-size: 20px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  color: #999999;
  text-align: left;
  img {
    vertical-align: middle;
  }
  & > span {
    font-size: 18px;
    font-weight: bold;
    color: #333333;
    vertical-align: middle;
    margin-left: 10px;
  }
  .go_back {
    float: right;
    width: 80px;
    height: 30px;
    margin-top: 20px;
    line-height: 30px;
    background: #5889dc;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 400;
    color: #ffffff;
    text-align: center;
    cursor: pointer;
  }
}
/deep/ .el-breadcrumb {
  float: left;
}
/deep/ .el-breadcrumb__item {
  font-size: 20px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  color: #999999;
  line-height: 38px;
}
/deep/ .el-breadcrumb__inner.is-link {
  font-weight: 400;
  color: #999;
}
/deep/ .el-breadcrumb__item .el-breadcrumb__inner,
.el-breadcrumb__item .el-breadcrumb__inner a,
.el-breadcrumb__item .el-breadcrumb__inner a:hover,
.el-breadcrumb__item .el-breadcrumb__inner:hover {
  color: #999;
  cursor: pointer;
}

// 表格分页样式修改
.el-pagination {
  text-align: right;
}
/deep/ .el-pager li {
  margin: 0 8px;
  width: 40px;
  height: 40px;
  line-height: 40px;
  font-size: 16px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  background: #fafafa;
  color: #666666;
  box-shadow: 0px 0px 4px 0px rgba(86, 86, 86, 0.11);
  border-radius: 6px;
}

/deep/ .el-pager li.active {
  color: #fff;
  background: #5889dc;
  box-shadow: 0px 0px 3px 0px rgba(0, 50, 89, 0.4);
  border-radius: 6px;
}

/deep/ .el-pagination .el-icon-arrow-right:before {
  content: "";
  display: inline-block;
  width: 40px;
  height: 40px;
  background: url("~@img/atlas/icon-page-right.png") no-repeat center;
}
/deep/
  .el-pagination
  button:disabled.btn-next:hover
  .el-icon-arrow-right:before {
  content: "";
  display: inline-block;
  width: 40px;
  height: 40px;
  background: url("~@img/atlas/icon-page-right.png") no-repeat center;
}
/deep/.el-pagination .btn-next:hover .el-icon-arrow-right:before {
  background: url("~@img/atlas/sidenav-hover2.png") no-repeat center;
}
/deep/ .el-pagination .el-icon-arrow-left:before {
  content: "";
  display: inline-block;
  width: 40px;
  height: 40px;
  background: url("~@img/atlas/icon-page-left.png") no-repeat center;
}
/deep/
  .el-pagination
  button:disabled.btn-prev:hover
  .el-icon-arrow-left:before {
  content: "";
  display: inline-block;
  width: 40px;
  height: 40px;
  background: url("~@img/atlas/icon-page-left.png") no-repeat center;
}
/deep/.el-pagination .btn-prev:hover .el-icon-arrow-left:before {
  background: url("~@img/atlas/sidenav-hover1.png") no-repeat center;
}
/deep/ .el-pagination button {
  width: 40px;
  height: 40px;
  padding: 0;
  background: #fafafa;
  box-shadow: 0px 0px 4px 0px rgba(86, 86, 86, 0.11);
  border-radius: 6px;
}
/deep/ .el-pagination__editor.el-input {
  margin: 0 8px;
}
/deep/ .el-pagination__editor.el-input .el-input__inner:focus {
  color: #5889dc;
}
/deep/ .el-pagination__editor.el-input .el-input__inner {
  height: 40px;
  background: #fafafa;
  box-shadow: 0px 0px 4px 0px rgba(86, 86, 86, 0.11);
  border-radius: 6px;
  font-size: 16px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  color: #cccccc;
}

/deep/ .el-pagination__jump {
  margin-left: 28px;
  height: 40px !important;
  line-height: 40px !important;
}
@media screen and (max-device-width: 1680px) {
  .epMain {
    overflow-y: auto;
    scrollbar-color: #767ffe #e9f3ff;
    scrollbar-width: 6px;
    scrollbar-width: thin;
    &::-webkit-scrollbar {
      width: 10px;
      height: 10px;
    }
    &::-webkit-scrollbar-thumb {
      border-radius: 10px;
      background: linear-gradient(0deg, #767ffe, #79aefe);
    }
    &::-webkit-scrollbar-track {
      background: #e9f3ff;
      border-radius: 10px;
    }
  }
  .list_item {
    height: 110px;
  }
}
/*分辨率低于1536，采用下面的样式*/
@media screen and (max-device-width: 1536px) {
  .epMain .epList {
    max-width: 1440px;
  }
  .list_item {
    width: 700px;
    margin-bottom: 10px;
  }
}
/*分辨率低于1440，采用下面的样式*/
@media screen and (max-device-width: 1440px) {
  .epMain .epList {
    max-width: 1366px;
  }
  .list_item {
    margin-bottom: 20px;
    width: 660px;
  }
}
@media only screen and (width: 1366px) {
  .epMain .epList {
    padding: 30px 20px;
    width: 100%;
    overflow-y: scroll;
  }
  .list_item {
    padding: 0 50px 0 80px;
    height: 120px;
    width: 100%;
  }
  /deep/ .el-pagination {
    text-align: center;
    margin-top: 60px;
  }
  .list_item .item_title {
    font-size: 22px;
  }
}
@media screen and (max-width: 1200px) {
  .epMain .epList {
    padding: 30px 20px 20px;
    width: 100%;
    overflow-y: scroll;
  }
  .list_item {
    padding: 0 50px 0 80px;
    width: 100%;
  }
  .head_crumbs {
    font-size: 16px;
  }
  /deep/ .el-breadcrumb__item {
    font-size: 16px;
  }
  .head_crumbs .go_back {
    height: 32px;
    line-height: 32px;
  }
  .list_item .flex_p span {
    font-size: 14px;
  }
  .list_item .item_title {
    font-size: 22px;
  }
}
</style>
